package zhang.utils;

import java.io.*;

import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;

public class XmlConReader {
	SAXReader read = new SAXReader();
	zhang.utils.JDBCInfo info = null;
	public XmlConReader(){
		try {
			Document doc = read.read(new File("src\\zhang\\utils\\config.xml"));
			Element dbinfo = doc.getRootElement().element("db-info");
			Element driverName = dbinfo.element("drivername");
			Element url = dbinfo.element("url");
			Element userName = dbinfo.element("username");
			Element password = dbinfo.element("password");
			info = new JDBCInfo(driverName.getStringValue(),url.getStringValue(),userName.getStringValue(),password.getStringValue());
		} catch (DocumentException e) {
			e.printStackTrace();
		}
		
	}
	public JDBCInfo getInfo() {
		return info;
	}
}
